/*
第一题：提示用户输入年月日信息，判断这一天是这一年中的第几天并打印
 */

import java.util.Scanner;

public class whichDay{
	public static void main(String[] args){
		// 读取用户数据
		System.out.println("请输入年份：");
		Scanner sc1 = new Scanner(System.in);
		int year = sc1.nextInt();
		System.out.println("请输入月份：");
		Scanner sc2 = new Scanner(System.in);
		int month = sc2.nextInt();
		System.out.println("请输入日期：");
		Scanner sc3 = new Scanner(System.in);
		int day = sc3.nextInt();

		if(month == 1){
			System.out.println("该日期是一年中的第" + day + "天");
			return;
		}

		// 创建各个月份天数数组
		int[] numDays = new int[]{31,28,31,30,31,30,31,31,30,31,30,31};
		int[] leapNumDays = new int[]{31,29,31,30,31,30,31,31,30,31,30,31};

		// 判断用户输入年份是平年还是闰年
		boolean isLeapYear;
		if(year%100 == 0){
			if(year%400 == 0){
				isLeapYear = true;
			} else{
				isLeapYear = false;
			}
		} else{
			if(year%4 == 0){
				isLeapYear = true;
			} else{
				isLeapYear = false;
			}
		}

		// 计算用户输入的日期是一年中的第几天
		int days = 0;
		int i;

		if(isLeapYear){
			for(i=0; i<month-1; i++){
				days += leapNumDays[i];
			}
		} else{
			for(i=0; i<month-1; i++){
				days += numDays[i];
			}
		}
		days += day;

		System.out.println("该日期是一年中的第" + days + "天");
	}
}

